package com.sskj.givecoin.p.fragment;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.sskj.givecoin.MyAppLication;
import com.sskj.givecoin.m.HttpConfig;
import com.sskj.givecoin.m.bean.FundListBean;
import com.sskj.givecoin.m.bean.HttpData;
import com.sskj.givecoin.m.http.JsonCallBack;
import com.sskj.givecoin.p.base.BasePresenter;
import com.sskj.givecoin.v.fragment.FundManagementFtagment;

/**
 * ProjectName：new_bfex
 * DESC: (类描述)
 * Created by 李岩 on 2018/7/12 0012
 * updateName:(修改人名称)
 * updateTime:(修改时间)
 * updateDesc:(修改内容)
 */
public class FundFragmentPresenter extends BasePresenter<FundManagementFtagment> {
    private int page = 1;


    /**
     * 请求基金分红记录
     * @param isRefresh
     */
    public void requestChildAtAData(boolean isRefresh){
        if (isRefresh){
            page = 1;
        }
        OkGo.<HttpData<FundListBean>>post(HttpConfig.BASE_URL + HttpConfig.FUND_LIST)
                .params("account", MyAppLication.getAccount())
                .params("p", page)
                .execute(new JsonCallBack<HttpData<FundListBean>>() {
                    @Override
                    protected void _onSuccess(Response<HttpData<FundListBean>> response) {
                        page++;
                        mView.onDataSuccess(response.body().getData().getList(), isRefresh);
                    }
                });
    }

    /**
     * 请求基金挖矿记录
     * @param isRefresh
     */
    public void requestChildAtBData(boolean isRefresh){
        if (isRefresh){
            page = 1;
        }
        OkGo.<HttpData<FundListBean>>post(HttpConfig.BASE_URL + HttpConfig.FUND_MINING_LIST)
                .params("account", MyAppLication.getAccount())
                .params("p", page)
                .execute(new JsonCallBack<HttpData<FundListBean>>() {
                    @Override
                    protected void _onSuccess(Response<HttpData<FundListBean>> response) {
                        page ++;
                        mView.onDataSuccess(response.body().getData().getList(), isRefresh);
                    }
                });
    }
}
